'''
Author: BujJieLi chengjie.li1@pacteraedge.com
Date: 2023-01-18 14:37:07
LastEditors: BujJieLi chengjie.li1@pacteraedge.com
LastEditTime: 2023-01-18 18:39:47
FilePath: /Dwarf/dwarf_debugger/config.py
Description: 

Copyright (c) 2023 by BujJieLi chengjie.li1@pacteraedge.com, All Rights Reserved. 
'''
from enum import IntEnum
from capstone import *
from capstone.arm64_const import *

class DisassemblyArch(IntEnum):
    DisassArch_Arm32 = 0
    DisassArch_Arm64 = 1
    DisassArch_X86 = 2
    DisassArch_X86_64 = 3

class DwarfConfig(object):
    '''
    静态对象
    用作Dwarf配置
    '''
    __instance = None
    disassembly_arch = DisassemblyArch.DisassArch_Arm32

    def __new__(self) -> None:
        if self.__instance is None:
            self.__instance = object.__new__(self)
        return self.__instance
    
    @staticmethod
    def disassArch():
        return {DisassemblyArch.DisassArch_Arm32: (CS_ARCH_ARM, CS_MODE_THUMB),
         DisassemblyArch.DisassArch_Arm64: (CS_ARCH_ARM64, CS_MODE_LITTLE_ENDIAN),
         DisassemblyArch.DisassArch_X86: (CS_ARCH_X86, CS_MODE_32),
         DisassemblyArch.DisassArch_X86_64: (CS_ARCH_X86, CS_MODE_64)
         }[DwarfConfig.disassembly_arch]